package com.gis.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gis.entity.EcologyData;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface EcologyDataMapper extends BaseMapper<EcologyData>{


    @Select("SELECT * " +
            "FROM biology_data " +
            "WHERE station_id = #{id} " +
            "AND (year >= #{fromYear} AND year <= #{toYear}) " +
            "ORDER BY year ASC, " +
            "         CASE " +
            "             WHEN season = 'spring' THEN 4 " +
            "             WHEN season = 'summer' THEN 3 " +
            "             WHEN season = 'fall' THEN 2 " +
            "             WHEN season = 'winter' THEN 1 " +
            "             ELSE 5 " +
            "         END DESC")
    List<EcologyData> getFromYear(@Param("id") int stationId, int fromYear, int toYear);
}
